import request from "@/utils/request";
import type { LoginForm, DataType, LoginReuqestData, userInfo } from "./type";
export const Login = (data: LoginForm) => {
  return request<LoginReuqestData<DataType>, any>({
    url: "/api/v1/auth/login",
    method: "post",
    data: {
      data,
    },
  });
};
// export const UserInfo = () => {
//   return request<LoginReuqestData<userInfo>>({
//     url: "/user/info",
//     method: "get",
//   });
// };
// 用户信息
export const UserInfo = (data: any) => {
  return request<LoginReuqestData<userInfo>, any>({
    url: "/api/v1/users/me",
    method: "post",
    data: {
      data,
    },
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
// 分页列表
export const UserList = (data: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/users/page",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const addUser = (data: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/users/add",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const delUser = (data: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/users/delete",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const addFormUser = (id: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/users/form",
    method: "post",
    data: id,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};

export const editUserPassword = (data: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/users/password",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const editUserStatus = (data: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/users/status",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const updateUserStatus = (data: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/users/update/",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const getRoleOptions = (aesKeyByRsa: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/roles/options",
    method: "post",
    data: aesKeyByRsa,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const LibraryOptions = (aesKeyByRsa: string) => {
  return request<any>({
    url: "/api/v1/library/options",
    method: "post",
    data: aesKeyByRsa,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
// 分页列表
export const getManageList = (data: any) => {
  return request<LoginReuqestData<any>, any>({
    url: "/api/v1/information/unreadPage",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export function editStatus(data: any) {
  return request({
    url: `/api/v1/information/updateReadStatus`,
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
}
